﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DrugStore.Helper;

namespace DrugStore.Models
{
    #region Models

        public class HomeModel
        {
            public PaginateList<Product> Products { get; set; }
            public PaginateList<News> MedicalNews { get; set; }
            public PaginateList<News> HealthNews  { get; set; }
            public PaginateList<DiseaseCategory> DiseaseCategories { get; set; }
            public News medicalNew{get;set;}
            public News healthNew{get;set;}
            
            //Contructor.
            public HomeModel() 
            {
                ProductBussiness productBussiness = new ProductBussiness();
                NewBussiness newBussiness = new NewBussiness();
                DiseaseCategoryBussiness dieseaseCategory = new DiseaseCategoryBussiness();
                var products = productBussiness.GetAllProducts();
                var healthNews = newBussiness.GetHealthNews();
                var medicalNews = newBussiness.GetMedicalNews();
                var categories = dieseaseCategory.GetAllDieseaseCategory();
                medicalNew = newBussiness.GetMedicalNew();
                healthNew = newBussiness.GetHealthNew();
                if (products != null)
                    Products = new PaginateList<Product>(products, 1, 3, null, null, null, null);
                else
                    Products = new PaginateList<Product>();
                if (medicalNews != null)
                    MedicalNews = new PaginateList<News>(medicalNews, 1, 3, null, null, null, null);
                else MedicalNews = new PaginateList<News>();
                if (HealthNews != null)
                    HealthNews = new PaginateList<News>(healthNews, 1, 3, null, null, null, null);
                else HealthNews = new PaginateList<News>();
                if (categories != null)
                    DiseaseCategories = new PaginateList<DiseaseCategory>(categories, 1, 3, null, null, null, null);
                else DiseaseCategories = new PaginateList<DiseaseCategory>();
            }            
        }

    #endregion
    
}